home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
MATH
/
RNDGEN10
/
MD2P31.ASM
next >
Wrap
Assembly Source File
|
1993-12-06
|
1KB
|
62 lines
; MD2P31.ASM, for Turbo Assembler
.MODEL TPASCAL ; 16-bit segments
.386C ; non-privileged 386 instructions
CODE SEGMENT BYTE PUBLIC
ASSUME cs:CODE,ds:NOTHING
; PASCAL declaration
; PROCEDURE MD2P31 (A,B : longint;
; VAR Q,R : longint); far; external;
; calculate product a*b, represent product as q*2^31+r, 0<=r<2^31
; return q and r
; Parameters (+2 because of push bp)
R EQU DWORD PTR ss:[bp+6]
Q EQU DWORD PTR ss:[bp+10]
B EQU DWORD PTR ss:[bp+14]
A EQU DWORD PTR ss:[bp+18]
MD2P31 PROC FAR
PUBLIC MD2P31
push bp
mov bp,sp ;get pointer into stack
push es
push di ;manual says we don't need to save
push eax ;those registers, but safety first!
push ebx
push edx
mov eax,a
mov ebx,b
imul ebx ; a*b in edx:eax
mov ebx,eax
SHLD edx,ebx,1 ; edx contains q
and eax,07fffffffh ; eax contains r
les di,r
stosd
mov eax,edx
les di,q
stosd
pop edx
pop ebx
pop eax
pop di
pop es
pop bp
retf 16 ;parameters take 16 bytes
MD2P31 ENDP
CODE ENDS
END